<script>
    var type = 'partner';
    var userIsGuest = Number('<?php echo Yii::app()->user->isGuest; ?>'.replace(/\D+/g,""));
</script>
<script src="/js/subscribe.js"></script>
    <div class="new_partner_block_head padding40">
        <div class="pull-left">Новые <br/> 
   
        </div>
        <?php if(Yii::app()->user->isGuest) : ?>
            <div class="signForum pull-left" href="javascript:void(0);" >Подписаться на обновления</div>
        <?php else : ?>
            <div class="<?php echo $isUserSign ? 'unsubscr' : 'signForum' ?> pull-left" href="javascript:void(0);" data-type="partner" data-typeId="0" data-userId="<?php echo Yii::app()->user->getId(); ?>" >
                <?php echo $isUserSign ? 'Отписаться' : 'Подписаться на обновления'; ?> 
            </div>
        <?php endif; ?>

    <div id="subscrWindow" class="subscrible_form pull-left hide"> 
    <?php $userEmail = !Yii::app()->user->isGuest ? Yii::app()->user->getState('email') : ''; ?>
    <?php echo CHtml::textField('', $userEmail, array('id'=>'subscrEmail','class'=>'subscrible_input')); ?>
    <div class="subscrible_sub" id="submitSubscrWindow"> </div>
    </div>
     <span class="hidePartnersList show_cat pull-right" >&nbsp;</span>
    </div> 
    <div id="lastPartnersList" >  
        <div class="new_partner_wrap pull-left">  
            <?php 
            $b=1;
            foreach($newPartners as $item) : ?>
                    <div class="partner_home_block  pull-left  <?php if($b < 4){ ?>partner_block_b_b<?php } if($b==1 || $b==2 || $b==4 || $b==5){ ?> partner_block_b_r  <?php } ?>">
                        <div class="home_block_wrap">
                        <div class="partner_home_cat_name"><?php echo $item['catName']; ?></div>
                        <?php $partnerParams = array('catId'=>$item['catId'], 'partnerUrl'=>$item['url']); ?>
                        <h2><a href="<?php echo Yii::app()->createUrl('partner/profile/index', $partnerParams);?> "><?php echo $item['name']; ?></a></h2>
                        <?php if(!empty($item['subCats'])) : ?>    
                            <ul class="inline unstyled home_subcats">
                                <?php for($i=0; $i<count($item['subCats']); $i++) : ?>
                                    <li class="subcats<?php echo($i); ?>">
                                        <a href="<?php echo Yii::app()->createUrl('partner/default/cat', array('catId'=>$item['subCats'][$i]['catId'], 'parentId'=>$item['subCats'][$i]['parentId']));?> "> <?php echo $item['subCats'][$i]['name']; ?></a>
                                    </li>&nbsp;&nbsp;
                                <?php endfor; ?>    
                            </ul>
                        <?php endif; ?>
                        <div class="partner_block_about">
                            <?php echo CPartnerkiHelper::getShortText($item['about'], 150); ?>
                        </div> 
                        </div>
                        
                        <?php if($item['type'] =='Простая регистрация') : ?>
                            <a  class="btn btn-partn"  href="<?php echo Yii::app()->createUrl('site/refLink', array('name'=>$item['name'])); ?>" target="blank">Зарегистрироваться</a>
                        <?php else : ?>
                            <a  class="btn btn-partn"  href="<?php echo Yii::app()->createUrl('partner/profile/invite', $partnerParams); ?>">Получить инвайт</a>
                        <?php endif; ?>  
                   </div> 


             <?php 
             $b++;
             endforeach; ?>
        </div>     
        <div class="offset_main">  <a class="btn btn-view" href="<?php echo Yii::app()->createUrl('partner/default/calendar'); ?>">Посмотреть все</a> </div>
    </div>
    
    
   <div class="category_block_wrap">
    
     <?php if(!empty($cats)) : ?>
        <?php for ($i=0; $i<count($cats); $i++) : ?>
            <div class="category_home_block" id="hb_<?php echo $i;   ?>">
                <div class="category_block_header">
                    <span class="hidePartners show_cat pull-right" >&nbsp;</span>
                    <span class="cat_banner pull-right ">
                        <?php if(!empty($cats[$i]['code'])) : ?>
                            <?php echo $cats[$i]['code']; ?>
                        <?php else : ?>
                            <img src="/images/banners/cat_banner.png" alt="">
                        <?php endif; ?>
                    </span>
                    <a class="category_block_name" href="<?php echo Yii::app()->createUrl('partner/default/cat', array('catId'=>$cats[$i]['categoryId'])); ?>"><?php echo $cats[$i]['catName']; ?></a><br/>
                    <?php $params = $cats[$i]['parentId'] ? array('parentId'=>$cats[$i]['parentid'], 'catId'=>$cats[$id]['categoryId']) : array('catId'=>$cats[$i]['categoryId']); ?>
                    <a class="category_block_news_link" href="<?php echo Yii::app()->createUrl('partner/news/allCatNews', $params); ?>">Новости и аналитика</a>
                </div>

                <div  class="partnersList">
                    <?php 
                    $this->widget('application.widgets.CatsRatingGrid',  
                        array('dataProvider' => $dataProviderArr[$i],
                            'summaryText' => '',
                         //   'sort'=>array('name','mean','field1','field2','field3','field4','openDate','editorMark'),
                            'rowCssClassExpression'=>'$this->dataProvider->data[$row]["close"] ? "tr_class_close" : ""',
                            'cssFile' => false,
                            'zeroPartners'=>!empty($cats[$i]['zeroPart']) ? $cats[$i]['zeroPart'] : array(),
                            'itemsCssClass' => 'cat_rating_table',
                            'pager'=>array(
                                'class'=>'CLinkPager',
                                'header'=>'',
                            ),
                            'columns' => array (
                                array('name'=>'name', 'htmlOptions'=>array('class'=>'part_name'), 'header'=>'', 'type'=>'raw', 'value'=>'$data["close"] ? "<i style=\"float:right; \"  class=\"icon-lock\"></i><a class=\"table_cat_partner_name\" href=\"".Yii::app()->createUrl("partner/profile/index", array("partnerUrl"=>$data["url"], "catId"=>$data["catId"]))."\">".$data["name"]."</a>".$data["subCats"] : "<a class=\"table_cat_partner_name\" href=\"".Yii::app()->createUrl("partner/profile/index", array("partnerUrl"=>$data["url"], "catId"=>$data["catId"]))."\">".$data["name"]."</a>".$data["subCats"]'),
                                array('name'=>'mean', 'htmlOptions'=>array('class'=>'center_row'),'header'=>'Рейтинг',  'type'=>'raw', 'value'=>'!$data["close"] ? $data["mean"]>0 ? $data["mean"] >= $data["oldMean"] ? "<span class=\"rating_up_icon\">&nbsp;</span><span class=\"rating_up\">".round($data["mean"] - $data["oldMean"],1)."</span><span class=\"rating_value\">".round($data["mean"],1)."</span> <span class=\"count_rating\">".$data["votes"]."</span>" : "&#9660;<span style=\"color:red;font-size:10px;margin-right:10px\">".round($data["oldMean"] - $data["mean"],2)."</span><span class=\"rating_value\">".$data["mean"]."</span> <b>".$data["votes"]."</b>" : "<span title=\"Не достаточно данных для расчета\">n/a" : ""'),
                                array('name'=>'field1', 'htmlOptions'=>array('class'=>'center_row'), 'header'=>$cats[$i]['reviewRating1'],'type'=>'raw', 'value'=>'$data["field1"] > 0 ? round($data["field1"],2) : "<span title=\"Не достаточно данных для расчета\">n/a" '),
                                array('name'=>'field2', 'htmlOptions'=>array('class'=>'center_row'),'header'=>$cats[$i]['reviewRating2'], 'type'=>'raw', 'value'=>'$data["field2"] > 0 ? round($data["field2"],2) : "<span title=\"Не достаточно данных для расчета\">n/a"'),
                                array('name'=>'field3', 'htmlOptions'=>array('class'=>'center_row'),'header'=>$cats[$i]['reviewRating3'], 'type'=>'raw', 'value'=>'$data["field3"] > 0 ? round($data["field3"],2) : "<span title=\"Не достаточно данных для расчета\">n/a"'),
                                array('name'=>'field4', 'htmlOptions'=>array('class'=>'center_row'),'header'=>$cats[$i]['reviewRating4'], 'type'=>'raw', 'value'=>'$data["field4"] > 0 ? round($data["field4"],2) : "<span title=\"Не достаточно данных для расчета\">n/a"'),
                                array('name'=>'openDate','htmlOptions'=>array('class'=>'center_row'), 'header'=>'<i class="icon icon-off"></i>', 'type'=>'raw',  'value'=>'"<span style=\"font-size:11px;\">".$data["openDate"]."</span>"'),
                                array('name'=>'editorMark','htmlOptions'=>array('class'=>'center_row'), 'header'=>'<i class="icon icon-heart"></i>', 'type'=>'raw', 'value'=>'"<span class=\"icon_hearth".$data["editorMark"]."\"></span>"'),
                                array('name'=>'help', 'htmlOptions'=>array('class'=>'right_row'),  'header'=>'<a href="javascript:void(0);"  rel="popover" data-content="'.$cats[$i]['catratingrules'].'" data-original-title="Подсказка"><i class="icon icon-question-sign"></i></a>', 'type'=>'raw', 'value'=>''),
                                array('name'=>'close', 'visible'=>false, 'header'=>'', 'value'=>'$data["close"]'),
                            ),
                            'emptyText' => 'В данной категории нет партнерских программ. Пожалуйста попробуйте зайти через некоторое время.',
                    ));
                    ?>
                    
                    <div class="offset4 button_view_all">  <a class="btn btn-view" href="<?php echo Yii::app()->createUrl('partner/default/cat', array('catId'=>$cats[$i]['categoryId'])); ?>">Посмотреть все</a> </div>
                    
                </div>
            </div>    
          
        <?php endfor; ?>
    <?php endif; ?>
    
    </div>
    
     <div class="padding20 last_footer_block"> 
    
 
            
   <?php if(!empty($lastThemes)) : ?>
        <div class="span5">
            <h4 class="last_forum_title">Последние <a href="">темы</a> на форуме</h4>
              <div class="last_themes">  
               <?php foreach ($lastThemes as $item) : ?>
                    <?php $params = array('catId'=>$item['catId'], 'partnerUrl'=>$item['partnerUrl'], 'url'=>$item['url']); ?>
                    <a href="<?php echo Yii::app()->createUrl('partner/forum/theme', $params);?>" >
                      <?php echo CPartnerkiHelper::getShortText($item['title'], 40) ?>
                    </a><br/>    
               <?php endforeach; ?>
              </div>
        </div>
    <?php endif; ?>
    
    <?php if(!empty($lastPosts)) : ?>        
        <div class="span6">
         <h4  class="last_forum_title">Последние <a href="">сообщения</a> на форуме</h4>    
         
         <div class="bubble">
             
            <?php foreach ($lastPosts as $item) : ?>
           
               <?php $params = array('catId'=>$item['catId'], 'partnerUrl'=>$item['partnerUrl'], 'url'=>$item['url']); ?>
               <div class="user_forum_name pull-left"><a href="<?php echo Yii::app()->createUrl('user/profile/profile', array('login'=>$item['login'])); ?>">
                    <?php echo ($item['login']); ?>
                </a>
               </div>
               <div class="user_post_forum pull-left"> <?php echo CPartnerkiHelper::getShortText($item['text'], 50); ?></div>
               <div class="user_post_forum_count pull-left"><a href="<?php echo Yii::app()->createUrl('partner/forum/theme', $params); ?>"><?php echo $item['countComments']; ?></a></div>
               
            <?php endforeach; ?>
            <div class="clearfix"></div>
         </div> 
         <div class="bub"></div>
        </div>
   <?php endif; ?>         
            
            
</div>    



<div class="modal hide fade" id="myModal">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h3>Уведомление</h3>
  </div>
  <div class="modal-body">
    
  </div>
  <div class="modal-footer">
    <a href="#" class="btn">Закрыть</a>
    
  </div>
</div>







